class Solution:
    def removeOccurrences(self, s: str, part: str) -> str:
        res = ""
        for string in s:
            res += string
            if res[-1] == part[-1] and len(res) >= len(part):
                if res[len(res) - len(part):] == part:
                    res = res[:len(res) - len(part)]
        return res
